package com.ww.scm.entity.mat;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.ww.scm.entity.AbstractEntity;
import com.ww.scm.entity.pub.Dictionary;

@Entity
@Table(name = "T_MAT_STORAGE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
// 现存量
public class Storage extends AbstractEntity {

	// 物料
	private Dictionary materiel;
	// 数量
	private Double amount=0.0;
	// 重量
	private Double weight=0.0;
	// 物料地点
	private Dictionary entity;
	// 状态
	private Dictionary state;

	public Storage() {
	}
	
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
	@JoinColumn(name = "F_MATERIEL_ID")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Dictionary getMateriel() {
		return materiel;
	}

	@Column(name = "F_AMOUNT", nullable = false, precision = 12, scale = 4)
	public Double getAmount() {
		return amount;
	}
	
	@Column(name = "F_WEIGHT", nullable = false, precision = 12, scale = 4)
	public Double getWeight() {
		return weight;
	}

	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
	@JoinColumn(name = "F_ENTITY_ID")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Dictionary getEntity() {
		return entity;
	}

	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
	@JoinColumn(name = "F_STATE_ID")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Dictionary getState() {
		return state;
	}

	public void setMateriel(Dictionary materiel) {
		this.materiel = materiel;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	public void setWeight(Double weight) {
		this.weight = weight;
	}

	public void setState(Dictionary state) {
		this.state = state;
	}

	public void setEntity(Dictionary entity) {
		this.entity = entity;
	}


}
